package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.OperateLogMapper;
import com.itheima.pojo.OperateLog;
import com.itheima.pojo.PageBean;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private OperateLogMapper operateLogMapper;

    /**
     * 分页查询日志
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public PageBean page(Integer page, Integer pageSize) {
//        1.设置分页参数
        PageHelper.startPage(page, pageSize);
//        2.调用Mapper层方法
        Page<OperateLog> logList =  operateLogMapper.page(page,pageSize);
//        3.返回Controller层
        return new PageBean(logList.getTotal(), logList.getResult());
    }
}
